<!-- 头部组件功能 -->
<template>
  <div>
    <div class="left">
      <div class="imgs">
        <img class="img" src="../assets/logo.png" alt="" />
      </div>
      <p class="wenzi">6浩集团后台管理</p>
    </div>

    <div class="right">
      <el-dropdown @command="handleCommand">
        <p class="imgbox">
          <img class="headerImg" :src="headerImg" alt="" />
        </p>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="a">个人信息</el-dropdown-item>
          <el-dropdown-item command="b">用户设置</el-dropdown-item>
          <el-dropdown-item command="c">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
      <p class="wenzi2">你好大哥:{{ name }}&nbsp;</p>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件
import { removeCookie } from '../utile/cookie'
import headerImg from '../assets/header.png'
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data () {
    //这里存放数据
    return {
      name: '',
      headerImg: headerImg
    };
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    handleCommand (command) {
      //   退出登录功能 
      if (command == 'c') {
        this.$message('退出成功');
        localStorage.removeItem('role')
        removeCookie('token')
        this.$router.go(0)
      }
    }
  },
  created () {
    this.name = localStorage.getItem('role')
  }
}
</script>
<style  scoped>
.el-dropdown {
  vertical-align: top;
}
.el-dropdown + .el-dropdown {
  margin-left: 15px;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.left {
  float: left;
}
.imgbox {
  float: right;
  width: 40px;
  height: 40px;
  margin-top: 10px;
}
.wenzi2 {
  float: left;
}
.headerImg {
  float: right;
  width: 100%;
  height: 100%;
}
.right {
  float: right;
}
.imgs {
  width: 200px;
  height: 100px;
  float: left;
}
.img {
  float: left;
  width: 100%;
  height: 100%;
}
.wenzi {
  float: left;
  font-size: 30px;
}
.el-container {
  height: 100%;
}
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
  /* width: auto !important; */
}
.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}
</style>